package com.bsj.sipgateway.command;


import com.bsj.tools.HexStr;

import java.io.Serializable;

/**
 * @author JIANG
 * @ClassName: RocketMqCommand
 * @Description: WEB命令下发实体类
 * @date 2019年7月10日 下午3:44:31
 */
public class RocketMqCommand implements Serializable {
    private static final long serialVersionUID = -2895342346788015385L;
    private int cmdType; // 命令类型，如点名[NAMED]
    private String cmdMessage; // 命令参数
    private long vehicleId; // 车辆ID
    private int groupId; // 车组ID
    private String userName; // 用户名
    private int userId; //用户Id
    private String uuid; // 指令ID
    private String retMsg; // status=0时，原因
    private String device; // 终端号
    // MQ消息从网关返回时的状态,2：表示设备在线，等待设备回复,1：表示成功,0：表示失败
    private int status;
    private long fdSessionId; //接公司FDFD协议,客户端id   //0x9206指令 回传的 索引sn
    // 设备返回消息体内容
    private byte[] body;
    private String spareMessage; //备用信息， 针对不同指令下发  附加不同信息。
    // 码流类型
    private int codeType;
    private String vip; //伪IP
    private long createTime;

    public RocketMqCommand() {
        super();
    }

    public RocketMqCommand(ComInfo info) {
        if (info != null) {
            this.uuid = info.getUuid();
            this.cmdType = info.getCmdType();
            this.cmdMessage = info.getParamMsg();
            this.device = info.getDevid();
        }
    }

    /**
     * <p>Title: </p>
     * <p>Description: </p>
     *
     * @param cmdType
     * @param spareMessage
     */
    public RocketMqCommand(int cmdType, String spareMessage) {
        super();
        this.cmdType = cmdType;
        this.spareMessage = spareMessage;
    }

    /**
     * <p>Title: </p>
     * <p>Description: </p>
     *
     * @param cmdType
     * @param vehicleId
     * @param groupId
     * @param device
     */
    public RocketMqCommand(int cmdType, long vehicleId, int groupId, String device) {
        super();
        this.cmdType = cmdType;
        this.vehicleId = vehicleId;
        this.groupId = groupId;
        this.device = device;
    }

    public RocketMqCommand(int cmdType, long vehicleId, int groupId, String device, String plate) {
        super();
        this.cmdType = cmdType;
        this.vehicleId = vehicleId;
        this.groupId = groupId;
        this.device = device;
        this.spareMessage = plate;
    }

    public RocketMqCommand(String uuid, int cmdType, long vehicleId, int groupId, String device, String plate) {
        super();
        this.uuid = uuid;
        this.cmdType = cmdType;
        this.vehicleId = vehicleId;
        this.groupId = groupId;
        this.device = device;
        this.spareMessage = plate;
    }

    public RocketMqCommand(int cmdType, String cmdMessage, long vehicleId, String userName, String uuid) {
        super();
        this.cmdType = cmdType;
        this.cmdMessage = cmdMessage;
        this.vehicleId = vehicleId;
        this.userName = userName;
        this.uuid = uuid;
    }

    public RocketMqCommand(int cmdType, String cmdMessage, long vehicleId, String userName, String uuid,
                           String device) {
        super();
        this.cmdType = cmdType;
        this.cmdMessage = cmdMessage;
        this.vehicleId = vehicleId;
        this.userName = userName;
        this.uuid = uuid;
        this.device = device;
    }

    public RocketMqCommand(int cmdType, String cmdMessage, long vehicleId, String userName, String uuid, String device,
                           String spareMessage, int userId) {
        super();
        this.cmdType = cmdType;
        this.cmdMessage = cmdMessage;
        this.vehicleId = vehicleId;
        this.userName = userName;
        this.uuid = uuid;
        this.device = device;
        this.userId = userId;
        this.spareMessage = spareMessage;
    }

    public RocketMqCommand(int cmdType, String uuid, String device, int status) {
        super();
        this.cmdType = cmdType;
        this.uuid = uuid;
        this.device = device;
        this.status = status;
    }

    public RocketMqCommand(int cmdType, String device, byte[] body) {
        super();
        this.cmdType = cmdType;
        this.device = device;
        this.body = body;
        this.uuid = "heartbeat";
    }


    public void fail(String retMsg) {
        this.status = 0;
        this.retMsg = retMsg;
    }

    public void success() {
        this.status = 1;
    }

    public void waitResponse() {
        this.status = 2;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public void setRetMsg(String retMsg) {
        this.retMsg = retMsg;
    }

    public String getDevice() {
        return device;
    }

    public void setDevice(String device) {
        this.device = device;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public int getCmdType() {
        return cmdType;
    }

    public void setCmdType(int cmdType) {
        this.cmdType = cmdType;
    }

    public String getCmdMessage() {
        return cmdMessage;
    }

    public void setCmdMessage(String cmdMessage) {
        this.cmdMessage = cmdMessage;
    }

    public long getVehicleId() {
        return vehicleId;
    }

    public void setVehicleId(long vehicleId) {
        this.vehicleId = vehicleId;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public byte[] getBody() {
        return body;
    }

    public void setBody(byte[] body) {
        this.body = body;
    }

    public long getFdSessionId() {
        return fdSessionId;
    }

    public void setFdSessionId(long fdSessionId) {
        this.fdSessionId = fdSessionId;
    }

    public String getSpareMessage() {
        return spareMessage;
    }

    public void setSpareMessage(String spareMessage) {
        this.spareMessage = spareMessage;
    }

    public int getCodeType() {
        return codeType;
    }

    public void setCodeType(int codeType) {
        this.codeType = codeType;
    }

    public String getVip() {
        return vip;
    }

    public void setVip(String vip) {
        this.vip = vip;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    /**
     * <p>Title: toString</p>
     * <p>Description: </p>
     *
     * @return
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return "RocketMqCommand{" +
                "cmdType=" + cmdType +
                ", cmdMessage='" + cmdMessage + '\'' +
                ", vehicleId=" + vehicleId +
                ", groupId=" + groupId +
                ", userName='" + userName + '\'' +
                ", userId='" + userId + '\'' +
                ", uuid='" + uuid + '\'' +
                ", retMsg='" + retMsg + '\'' +
                ", device='" + device + '\'' +
                ", status=" + status +
                ", fdSessionId=" + fdSessionId +
                ", body=" + HexStr.toStr(body) +
                ", spareMessage='" + spareMessage + '\'' +
                ", codeType=" + codeType +
                ", vip='" + vip + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}